package xinyu.customer.dialog;

import android.app.Dialog;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;

import xinyu.customer.R;


/**
 * Created by Xuze on 2019/1/17.
 */

public class SecretDialog extends Dialog {




    private int DIALOG_WIDTH;


    private OnDialogDissmissLisener   lisener;


    public void setLisener(OnDialogDissmissLisener lisener) {
        this.lisener = lisener;
    }

    public SecretDialog(final Context context) {
        super(context, R.style.dialog_default_style);
        setContentView(R.layout.dialog_scerect);
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        View mContentView = super.findViewById(R.id.re_root_layout);
        if (DIALOG_WIDTH == 0) {
            DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
            DIALOG_WIDTH = (int) (displayMetrics.widthPixels * Float.parseFloat(context.getResources().getString(R.string.dialog_middle_width)));
        }
        ViewGroup.LayoutParams rootLayoutParams = mContentView.getLayoutParams();
        rootLayoutParams.width = DIALOG_WIDTH;
        mContentView.requestLayout();


        findViewById(R.id.tv_bind).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                 dismiss();
                 if (lisener!=null){
                     lisener.onDialogClick(true);
                 }
            }
        });
        findViewById(R.id.tv_unbind).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (lisener!=null){
                    lisener.onDialogClick(false);
                }
            }
        });

        findViewById(R.id.tv_web_tip).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                WebActivity.start(getContext(), WebActivity.TYPE_RULES);
            }
        });


    }


    public  interface   OnDialogDissmissLisener{


        void onDialogClick(boolean confirm);

    }


}

